package com.azdebugit.threadlocal;

public class ThreadLocalExsample {

  private static   ThreadLocal<Long> longLocal = new ThreadLocal<>();
    public void set() {
        longLocal.set(Thread.currentThread().getId());
    }
    public long getLong() {
        return longLocal.get();
    }
 public static void main(String[] args) {
        ThreadLocalExsample test = new ThreadLocalExsample();
        //注意:没有set之前，直接get，报null异常了
     test.set();
        System.out.println("-------threadLocal value-------" + test.getLong());
     longLocal.remove();
    }
}